package multithreaded.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolSample1 {
    public static void main(String[] args) {
        // 定长线程池的特点是固定线程总数，空闲线程用于执行任务，如果线程都在使用，后续任务则处于等待状态
        ExecutorService threadPool = Executors.newFixedThreadPool(10);

        for (int i = 1; i < 1000; i++) {
            int finalI = i;
            threadPool.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + ":" + finalI);
                }
            });
        }
        threadPool.shutdown();

    }
}
